package views  
{
	import flash.events.Event;
	
	import qnx.views.UIView;
	
	public class BaseView extends UIView
	{
		
		public var isOnStage:Boolean = false;
		
		public function BaseView()
		{
			init();
		}
		
		protected function init():void
		{
			addEventListener( Event.ADDED_TO_STAGE, onAddedEvent );
		}
		
		
		private function onAddedEvent(event:Event):void 
		{
			removeEventListener( Event.ADDED_TO_STAGE, onAdded );
			addEventListener( Event.REMOVED_FROM_STAGE, onRemoved );
			this.isOnStage = true;
			onAdded();
		}
		
		protected function onAdded(event:Event = null):void{}
		protected function onRemoved(event:Event = null):void{}
		
		private function onRemovedEvent(event:Event):void
		{
			this.isOnStage = false;
			removeEventListener( Event.REMOVED_FROM_STAGE, onRemoved );
			addEventListener( Event.ADDED_TO_STAGE, onAdded );
			onRemoved();
		}
	}
}